import request from '@/config/axios'
import type { Dayjs } from 'dayjs';

/** 施工单位信息 */
export interface ConstructionUnit {
          id: number; // 主键
          name?: string; // 企业名称
          corporation?: string; // 法人
          description: string; // 描述
          contact?: string; // 联系人
          contactPhone?: string; // 联系电话
          status?: number; // 状态
  }

// 施工单位 API
export const ConstructionUnitApi = {
  // 查询施工单位分页
  getConstructionUnitPage: async (params: any) => {
    return await request.get({ url: `/project/construction-unit/page`, params })
  },
  // 获取施工单位精简信息列表
  getSimpleConstructionUnitList: async (): Promise<ConstructionUnit[]> => {
    return await request.get({ url: '/project/construction-unit/simple-list' })
  },

  // 查询施工单位详情
  getConstructionUnit: async (id: number) => {
    return await request.get({ url: `/project/construction-unit/get?id=` + id })
  },

  // 新增施工单位
  createConstructionUnit: async (data: ConstructionUnit) => {
    return await request.post({ url: `/project/construction-unit/create`, data })
  },

  // 修改施工单位
  updateConstructionUnit: async (data: ConstructionUnit) => {
    return await request.put({ url: `/project/construction-unit/update`, data })
  },

  // 删除施工单位
  deleteConstructionUnit: async (id: number) => {
    return await request.delete({ url: `/project/construction-unit/delete?id=` + id })
  },

  /** 批量删除施工单位 */
  deleteConstructionUnitList: async (ids: number[]) => {
    return await request.delete({ url: `/project/construction-unit/delete-list?ids=${ids.join(',')}` })
  },

  // 导出施工单位 Excel
  exportConstructionUnit: async (params) => {
    return await request.download({ url: `/project/construction-unit/export-excel`, params })
  },
}
